var date=['Iphone5','Ipad','50块充值卡','三星笔记本','惠普打印机','谢谢参与','佳能打印机','1000超市购物卷'];
    timer=null;
    flag=0;
window.onload=function(){
var begin=document.getElementById('begin');
    stop=document.getElementById('stop');
//鼠标事件
    begin.onclick=playFun; 
	stop.onclick=stopFun;
//键盘事件
    document.onkeyup=function(event){
		event =  event || window.event;
		if(event.keyCode==13){
			if(flag==0){
				playFun();
				flag=1;
			}
			else{
				stopFun();
				flag=0;
			}
		}
		}	
}
//开始抽奖
function playFun(){
 
 var begin=document.getElementById('begin');
 var title=document.getElementById('title');
 clearInterval(timer);
	
	timer=setInterval(function(){
    	var random=Math.floor(Math.random()*date.length);
	        title.innerHTML=date[random];
},50);
begin.style.backgroundColor='#999';
}
function stopFun(){
	clearInterval(timer);
	var begin=document.getElementById('begin');
	begin.style.background='blue';
	}